package com.test.ipc.pipe;

import com.test.ipc.Logger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Child {
    private static final String TAG = "Pipe.Child";

    public static void main(String[] args) {

        Thread readThread = new Thread(new Runnable() {
            @Override
            public void run() {
                BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
                while (true) {
                    try {
                        String line = bfr.readLine();
                        if (line != null) {
                            //Logger.d(TAG + ",Rcv: " + line);
                            String str = "hi:" + line + "\r\n";
                            System.out.println(str);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        Logger.e(TAG+","+e.getMessage());
                        break;
                    }
                }
            }
        });
        readThread.start();

        try {
            readThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
